package com.zdw.test2;

import com.zdw.test2.utils.JdbcUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * Author: Zhang Dongwei
 * Date: 2022/4/3 19:47
 */
public class TestSelect {
    public static void main(String[] args) {
        Connection conn = null;
        Statement st = null;
        ResultSet rs = null;
        try {
            conn = JdbcUtils.getConnection();
            st = conn.createStatement();
            // sql
            String sql = "select * from users where id=1";
            rs = st.executeQuery(sql); // 查询完毕会返回结果集

            if(rs.next()){
                System.out.println(rs.getString("NAME"));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            JdbcUtils.release(conn,st,rs);
        }
    }
}
